<!DOCTYPE html>
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>新增地址</title>


<!--[if lt IE 9]>
<script src="__STATIC__/register/js/html5shiv.js"></script>
<![endif]-->

<link href="__STATIC__/register/css/normalize.css" rel="stylesheet"/>
<link href="__STATIC__/register/css/jquery-ui.css" rel="stylesheet"/>
<link href="__STATIC__/register/css/jquery.idealforms.min.css" rel="stylesheet" media="screen"/>

<style type="text/css">
body{font:normal 15px/1.5 Arial, Helvetica, Free Sans, sans-serif;color: #222;background:url('__STATIC__/register/pattern.png');overflow-y:scroll;padding:60px 0 0 0;}
#my-form{width:755px;margin:0 auto;border:1px solid #ccc;padding:3em;border-radius:3px;box-shadow:0 0 2px rgba(0,0,0,.2);}
#comments{width:350px;height:100px;}
</style>

</head>
<body>


<div class="row">

<div class="eightcol last">

<!-- Begin Form -->

<form id="my-form" action="">

<section name="填写地址">
<div><label>收货人：</label><input id="take_user" name="take_user" type="text" placeholder="请输入收货人~"/></div>
<div><label>省（市）：</label><input id="provence" name="provence" type="text" placeholder="请输入所在省（市）~"/></div>
<div><label>市（区）:</label><input id="city" name="city" type="text" placeholder="请输入所在市（区）~"/></div>
<div><label>县（区）</label><input id="country" name="country" type="text" placeholder="请输入所在区（县）~" /></div>
<div><label>街道详情：</label><textarea id="detail" name="detail" type="text" placeholder="请输入所在区（县）~" ></textarea></div>
<!-- <div><label>出生日期:</label><input name="date" class="datepicker" data-ideal="date" type="text" placeholder="月/日/年"/></div>-->
<!-- <div><label>上传头像:</label><input id="file" name="file" multiple type="file"/></div>-->
<div><label>收货电话电话:</label><input name="phone" placeholder="请输入电话号码~" type="text"/></div>
</section>

<div><hr/></div>

<div>
<button  type="button" id="submit">提交</button>
<button id="reset" type="button">重置</button>
</div>

</form>

<!-- End Form -->

</div>

</div>


<script type="text/javascript" src="__STATIC__/register/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="__STATIC__/register/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/register/js/jquery.idealforms.js"></script>
<script type="text/javascript">
    var options = {

        /*	onFail: function(){
            /!*alert( $myform.getInvalid().length +' invalid fields.' )*!/
          },

          inputs: {
            'password': {
              filters: 'required password',
            },
            'username': {
              filters: 'required username',
              data: {
              //ajax: { url:'validate.php' }
              }
            },
            'file': {
              filters: 'extension',
              data: { extension: ['jpg'] }
            },
            'comments': {
              filters: 'min max',
              data: { min: 50, max: 200 }
            },
            'states': {
              filters: 'exclude',
              data: { exclude: ['default'] },
              errors : {
                exclude: '选择国籍.'
              }
            },
            'langs[]': {
              filters: 'min max',
              data: { min: 2, max: 3 },
              errors: {
                min: 'Check at least <strong>2</strong> options.',
                max: 'No more than <strong>3</strong> options allowed.'
              }
            }
          }*/

    };
    $('#reset').click(function(){
        $myform.reset().fresh().focusFirst()
    });
    var $myform = $('#my-form').idealforms(options).data('idealforms');

    $(function() {
        $('#submit').click(function() {
            var d = {};
            var t = $('form').serializeArray();
            $.each(t, function() {
                d[this.name] = this.value;
            });
            var data = d;
            var url = '{:url("/user/add_address")}';
            $.post(url,data,function(data){
                if(data.code==0){
                    alert(data.msg);
                    //window.location.href = "{:url('user/login')}"
                }else if(data.code==1){
                    alert(data.msg);
                    window.location.href = "{:url('index/index')}"
                }
            },'json');
        });
    });
</script>
<div style="text-align:center;">
</div>
</body>
</html>